<?php
class Sig_Plugins_Acl extends Zend_Controller_Plugin_Abstract {

    private $_acl = null;

    public function __construct(Zend_Acl $acl) {
        $this->_acl = Zend_Registry::get('acl');
    }

    
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
    	$session = new Zend_Session_Namespace('role');
    	
    	$isAllowed = $this->_acl->isAllowed($session->role, 
                                            $request->getControllerName(),
                                            $request->getActionName());
    	if (!$isAllowed)
    	{
            $request->setControllerName('acesso');
            $request->setActionName('login');
            $request->setParam('semacesso', true);
            $this->postDispatch($request);
    	}
    }


    public function getAcl()
    {
        return $this->_acl;
    }


}